package com.vstudy.zx.dao;

import com.vstudy.zx.dao.provider.OutlineDaoProvider;
import com.vstudy.zx.entity.Outline;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface OutlineDao {
    @SelectProvider(type = OutlineDaoProvider.class, method = "selectByGradeSubject")
    List<Outline> selectBy(@Param("grade_id") Long grade_id, @Param("subject_id") Long subject_id);

    @Select("select * from tb_outline where o_id=#{id}")
    Outline selectById(Long id);

    @Select("select * from tb_outline where o_name like concat('%',#{key},'%')")
    @Results({
            @Result(column = "grade_id", property = "grade",
                    one = @One(select = "com.vstudy.zx.dao.GradeDao.selectById")),
            @Result(column = "subject_id", property = "subject",
                    one = @One(select = "com.vstudy.zx.dao.SubjectDao.selectById"))
    })
    List<Outline> selectByKeyWord(String key);


    @Select("select * from tb_outline where subject_id=#{subjectId}")
    List<Outline> selectBySubjectId(Long subjectId);
}
